{include file="public/user_shop_head" /}
{include file="public/href" /}
<link rel="stylesheet" type="text/css" href="__STATIC__/css-wap/style.css">
    <div class="main">
        <ul class="list">
            <li><span><a href="shop_index?shop_id={:input('shop_id')}">店铺首页</a></span></li>
            <li ><span><a href="all_goods?shop_id={:input('shop_id')}">全部商品</a></span></li>
            <li ><span><a href="{:url('user_category/sales_promote')}?promotion=1&shop_id={:input('shop_id')}">促销</a></span></li>
            <li><span><a href="new_list?shop_id={:input('shop_id')}">上新</a></span></li>
        </ul>
        <input type="hidden"  id="shop_id"  value="{:input('shop_id')}"  />
    </div>
    <div class="tip" id="tip">

    </div>
    <ul class="list_group" id="show_list"></ul>
{include file="public/shop_footer" /}
</div>
{include file="public/src" /}
<script>
    //搜索
    function search_title(){
        var shop_id = $('#shop_id').val(),
                search = $('#search').val();
        window.location.href="?shop_id="+shop_id+"&search="+search;
    }
    //未登录跳转到登录
    function jump_login(){
        layer.open({
            content: '您还未登录,请登录'
            ,btn: ['去登录', '取消']
            ,yes: function(index){
                window.location.href="{:url('mobile/user_port/login')}";
                layer.close(index);
            }
        });
    }
    //layer流加载
    layui.use('flow', function() {
        var $ = layui.jquery;
        var flow = layui.flow;
        flow.load({
            elem: '#show_list' //流加载容器
            , isAuto: true
            , isLazyimg: true
            , done: function (page, next) { //执行下一页的回调
                var lis = [];
                var shop_id = $('#shop_id').val();
                var search = $('#search').val();
                var p = {:input('promotion',0)};
                $.ajax({
                    url: "sales_promote",
                    dataType: 'json',
                    type: 'post',
                    data: {'page': page, 'shop_id': shop_id, 'search' : search,'promotion' : p},
                    success: function (t) {
                        if(t){
                            $('#tip').html('<p><span class="cir"></span><span class="note"> 以下商品促销 </span><span class="cir"></span></p>');
                        }
                        layui.each(t.data, function (index, item) {
                            var url = "{:url('mobile/user_category/goods_details')}?goods_id=" + item.id;
                            lis.push('<li><a href="' + url + '"><div class="pic"><img src="/' + item.thumb_img + '" style="height: 150px;" onerror=this.src="/static/mobile/img/empty_img.png" >' +
                                    '</div>' +
                                    '<h4 class="title">' + item.title + '</h4><div class="price">&yen;' + item.price + '<span class="sale_num">销量 ' + item.sale_number + '</p></div></a></li>');
                        });
                        next(lis.join(''), page < t.pages);
                    },
                    error: function () {
                        layer.open({content:'网络繁忙,请重试',skin:'msg',time:2});
                    }
                })
            }
        });
    });
</script>
</body>
</html>